package com.sbs.gaoxinqutoilet.fragment;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.ListPopupWindow;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lvfq.pickerview.TimePickerView;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.activity.AccepterActivity;
import com.sbs.gaoxinqutoilet.base.BaseBackFragment;
import com.sbs.gaoxinqutoilet.entity.AcceptImageEntity;
import com.sbs.gaoxinqutoilet.entity.AcceptanceEntity;
import com.sbs.gaoxinqutoilet.entity.CheckDetialTwoDataEntity;
import com.sbs.gaoxinqutoilet.entity.CheckItemEntity;
import com.sbs.gaoxinqutoilet.entity.FIleEditSaveUpEntity;
import com.sbs.gaoxinqutoilet.entity.MemberEntity;
import com.sbs.gaoxinqutoilet.entity.MessageEvent;
import com.sbs.gaoxinqutoilet.entity.UploadImageEntity;
import com.sbs.gaoxinqutoilet.entity.UserEntity;
import com.sbs.gaoxinqutoilet.eventbus.EventCenter;
import com.sbs.gaoxinqutoilet.eventbus.StartNewFragmentEvent;
import com.sbs.gaoxinqutoilet.http.HttpApis;
import com.sbs.gaoxinqutoilet.http.Request;
import com.sbs.gaoxinqutoilet.interfaces.Constants;
import com.sbs.gaoxinqutoilet.interfaces.PopuClickListener;
import com.sbs.gaoxinqutoilet.myapp.MyApplication;
import com.sbs.gaoxinqutoilet.utils.GsonTools;
import com.sbs.gaoxinqutoilet.utils.HttpUtils;
import com.sbs.gaoxinqutoilet.utils.ImageLoaderUtils;
import com.sbs.gaoxinqutoilet.utils.ImageUtils;
import com.sbs.gaoxinqutoilet.utils.LogUtils;
import com.sbs.gaoxinqutoilet.utils.NetTimeUtils;
import com.sbs.gaoxinqutoilet.utils.SPUtil;
import com.sbs.gaoxinqutoilet.utils.TimeUtils;
import com.sbs.gaoxinqutoilet.utils.ToastUtils;
import com.sbs.gaoxinqutoilet.utils.Util;
import com.sbs.gaoxinqutoilet.utils.UtilPop;
import com.sbs.gaoxinqutoilet.utils.appinstallerutils.ConstUtils;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.http.okhttp.OkHttpUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import me.codeboy.android.aligntextview.CBAlignTextView;
import me.iwf.photopicker.PhotoPicker;
import top.zibin.luban.Luban;

import static com.sbs.gaoxinqutoilet.R.id.rg_question_five;
import static com.sbs.gaoxinqutoilet.R.id.rg_question_four;
import static com.sbs.gaoxinqutoilet.R.id.rg_question_three;
import static com.sbs.gaoxinqutoilet.utils.JsonUtil.json2Collection;

/**
 * Created by 聪明一只哈 on 2018/6/2.
 * Time: 2018/6/2  11:03
 */

public class ToiletCheckDetialFragment extends BaseBackFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
    //假数据,传过来的值  存储在Bundle中
    private static final String CHECK_ITEM_BEAN = "checkItem_dataBean";

    private static final int LAYOUT_ONE = 0;
    private static final int LAYOUT_TWO = 1;
    private static final int LAYOUT_THREE = 2;
    private View view;


    private RadioButton rb_one_pass;
    private RadioButton rb_one_fail;
    private RadioButton rb_two_pass;
    private RadioButton rb_two_fail;
    private RadioButton rb_three_pass;
    private RadioButton rb_three_fail;
    private RadioButton rb_four_pass;
    private RadioButton rb_four_fail;
    private RadioButton rb_five_pass;
    private RadioButton rb_five_fail;
    private TextView tv_result;
    private TextView tv_group;
    private TextView tv_date_check_pickter;
    private EditText et_checkreason;
    private Button bt_check_save;
    private ScrollView applyBuySv;
    private ImageView toolbarBack;
    private TextView toolbarTitle;
    private Toolbar toolbar;


    private AutoRelativeLayout line_one_click_body;
    private AutoLinearLayout line_one_body;
    private ImageView line_one_arrow;
    private CBAlignTextView line_one_door_num;
    private CBAlignTextView line_one_door_name;
    private CBAlignTextView line_one_househole_num;
    private CBAlignTextView line_one_id_num;
    private CBAlignTextView line_one_idle;
    private CBAlignTextView line_one_build_state;
    private CBAlignTextView line_one_build_type;
    private CBAlignTextView rebuild_build_style;
    private CBAlignTextView line_one_build_year;
    private CBAlignTextView line_one_team_name;
    private CBAlignTextView line_one_state_material;
    private CBAlignTextView line_one_danwei;
    private AutoRelativeLayout line_two_click_body;
    private ImageView line_two_arrow;
    private AutoLinearLayout line_two_body;
    private TextView line_two_q_one;
    private TextView line_two_q_two;
    private TextView line_two_q_three;
    private TextView line_two_q_four;
    private TextView line_two_q_five;
    private TextView line_two_q_six;
    private TextView line_two_q_seven;
    private TextView line_two_q_eight;
    private TextView line_two_q_nine;
    private CheckItemEntity.DataBean checkItemBean;
    private CheckDetialRequest request;
    private ImageView imageview_b;
    private ImageView imageview_m;
    private ImageView imageview_f;
    private ImageView imageview_id;
    private ImageView imageview_df;
    private ImageView image_check_gaizaozhongtwo;
    private ImageView image_check_gaizaozhongthree;
    private RadioGroup rg_check_question_one;
    private RadioGroup rg_check_question_two;
    private RadioGroup rg_check_question_three;
    private RadioGroup rg_check_question_four;
    private RadioGroup rg_check_question_five;


    //存储参数的集合
    private Map<String, Object> qrbparams = new HashMap<>();
    private ListPopupWindow check_resault_popupWindow;

    //检查结果
    List<String> check_resaultlist = new ArrayList<>();
    private TimePickerView pvTime;
    private ArrayList<AcceptImageEntity> acceptImageEntities;
    private TextView tv_idcard;
    private TextView tv_frontdoor;
    private TextView tv_befor;
    private TextView tv_ing;
    private TextView tv_after;
    private TextView tv_check_gaizaozhongtwo;
    private TextView tv_check_gaizaozhongthree;
    private RadioGroup rg_check_question_six;
    private RadioGroup rg_check_question_seven;
    private RadioGroup rg_check_question_eight;
    private RadioGroup rg_check_question_nine;
    private RadioGroup rg_check_question_ten;
    private RadioGroup rg_check_question_eleven;
    private RadioGroup rg_check_question_twelve;
    private RadioGroup rg_check_question_thirdteen;
    private RadioGroup rg_check_question_fourteen;
    private RadioGroup rg_check_question_fifteen;
    private RadioGroup rg_check_question_sixteen;
    private RadioGroup rg_check_question_seventeen;
    private RadioButton rb_six_pass;
    private RadioButton rb_six_fail;
    private RadioButton rb_seven_pass;
    private RadioButton rb_seven_fail;
    private RadioButton rb_eight_pass;
    private RadioButton rb_eight_fail;
    private RadioButton rb_nine_pass;
    private RadioButton rb_nine_fail;
    private RadioButton rb_ten_pass;
    private RadioButton rb_ten_fail;
    private RadioButton rb_eleven_pass;
    private RadioButton rb_eleven_fail;
    private RadioButton rb_twelve_pass;
    private RadioButton rb_twelve_fail;
    private RadioButton rb_thirdteen_pass;
    private RadioButton rb_thirdteen_fail;
    private RadioButton rb_fouthteen_pass;
    private RadioButton rb_fouthteen_fail;
    private RadioButton rb_fifteen_pass;
    private RadioButton rb_fifteen_fail;
    private RadioButton rb_sixteen_pass;
    private RadioButton rb_sixteen_fail;
    private RadioButton rb_seventeen_pass;
    private RadioButton rb_seventeen_fail;
    private TextView line_two_q_five_six;
    private TextView line_two_q_five_seven;
    private TextView line_two_q_five_eight;
    private TextView line_two_q_five_nine;
    private TextView line_two_q_five_ten;
    private TextView line_two_q_five_eleven;
    private TextView line_two_q_five_twelve;
    private CBAlignTextView line_one_humans;
    private CBAlignTextView line_one_phones;
    private CBAlignTextView line_one_state_bianchi;
    private CBAlignTextView line_one_state_chongshui;
    private CBAlignTextView line_one_state_cefang;
    private TextView line_two_q_half;
    private RadioGroup rg_check_question_five_half;
    private RadioButton rb_five_pass_half;
    private RadioButton rb_five_fail_half;
    private TextView upimg_statue;
    private RelativeLayout up_check_rl_a;
    private RelativeLayout up_check_rl_b;
    private RelativeLayout up_check_xiang;
    private RelativeLayout up_check_xian;
    private RelativeLayout up_check_shi;
    private ImageView sell_check_one;
    private ImageView sell_check_two;
    private ImageView check_myFile_three;
    private ImageView check_myFile_four;
    private ImageView check_myFile_five;
    private ImageView image_check_a;
    private ImageView image_check_b;
    private ImageView image_check_xiang;
    private ImageView image_check_xian;
    private ImageView image_check_shi;
    private AutoLinearLayout all_show_a;
    private AutoLinearLayout all_show_b;
    private AutoLinearLayout alls_check_othertwo;
    private AutoLinearLayout all_check_det_unfail;
    private View view_a_check;
    private TextView tv_img_biao;
    private TextView tv_img_yijian;
    private TextView tv_img_xiang;
    private TextView tv_img_xian;
    private TextView tv_img_shi;
    private String netTime;
    private String opt_level;
    private String token_data;


    public static ToiletCheckDetialFragment newInstance(CheckItemEntity.DataBean checkDataBean) {

        Bundle args = new Bundle();
        args.putSerializable(CHECK_ITEM_BEAN, checkDataBean);
        ToiletCheckDetialFragment fragment = new ToiletCheckDetialFragment();
        fragment.setArguments(args);
        return fragment;
    }


    private Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case LAYOUT_ONE:
                    loadLayoutOne();
                    break;
                case LAYOUT_TWO:
                    loadLayoutTwo();
                    break;
                case LAYOUT_THREE:
                    initView(view);
                    initListener();
                    loadMoreData();
                    break;
                default:

            }
        }
    };

    /**
     * 加载前两个ViewStub
     */
    private void loadLayoutOne() {
        ViewStub infalte_usershow = (ViewStub) view.findViewById(R.id.inflat_check_build_state);
        ViewStub infalte_state = (ViewStub) view.findViewById(R.id.inflat_check_accept_state);
        ViewStub inflat_up_image = (ViewStub) view.findViewById(R.id.inflat_check_uploadimg);
        ViewStub infalte_questionlist = (ViewStub) view.findViewById(R.id.inflat_check_question_list);

        //第一个
        View inflate_one = infalte_usershow.inflate();
        line_one_click_body = (AutoRelativeLayout) inflate_one.findViewById(R.id.rebuild_reform_state_title);
        line_one_arrow = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_iv_arrow);
        line_one_body = (AutoLinearLayout) inflate_one.findViewById(R.id.rebuild_reform_state_show_body);

        line_one_humans = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_humans);
        line_one_phones = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_phone);

        line_one_danwei = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_located_address);
        line_one_door_num = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_door_num);
        line_one_door_name = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_door_name);
        line_one_househole_num = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_househole_num);
        line_one_id_num = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_id_num);
        line_one_idle = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_idle);
        line_one_build_state = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_build_state);
        line_one_build_type = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_build_type);
        rebuild_build_style = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_build_style);
        line_one_build_year = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_build_year);
        line_one_team_name = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_team_name);
        line_one_state_material = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_material);

        line_one_state_bianchi = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_bianchi);
        line_one_state_chongshui = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_chongshui);
        line_one_state_cefang = (CBAlignTextView) inflate_one.findViewById(R.id.rebuild_reform_state_cefang);


        all_show_a = (AutoLinearLayout) inflate_one.findViewById(R.id.alls_a_show);
        all_show_b = (AutoLinearLayout) inflate_one.findViewById(R.id.alls_b_show);
        alls_check_othertwo = (AutoLinearLayout) inflate_one.findViewById(R.id.alls_check_othertwo);
        imageview_b = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_befor_image);
        imageview_m = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_ing_image);
        imageview_f = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_after_image);
        imageview_id = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_idcard_image);
        imageview_df = (ImageView) inflate_one.findViewById(R.id.rebuild_reform_state_frontdoor_image);
        image_check_gaizaozhongtwo = (ImageView) inflate_one.findViewById(R.id.image_check_gaizaozhongtwo);
        image_check_gaizaozhongthree = (ImageView) inflate_one.findViewById(R.id.image_check_gaizaozhongthree);

        tv_idcard = (TextView) inflate_one.findViewById(R.id.tv_idcard_ima);
        tv_frontdoor = (TextView) inflate_one.findViewById(R.id.tv_frontdoor_ima);
        tv_befor = (TextView) inflate_one.findViewById(R.id.tv_befor_ima);
        tv_ing = (TextView) inflate_one.findViewById(R.id.tv_ing_ima);
        tv_after = (TextView) inflate_one.findViewById(R.id.tv_after_ima);
        tv_check_gaizaozhongtwo = (TextView) inflate_one.findViewById(R.id.tv_check_gaizaozhongtwo);
        tv_check_gaizaozhongthree = (TextView) inflate_one.findViewById(R.id.tv_check_gaizaozhongthree);


        //第二个
        View inflate_two = infalte_state.inflate();
        line_two_click_body = (AutoRelativeLayout) inflate_two.findViewById(R.id.rebuild_detial_accept_title);
        line_two_arrow = (ImageView) inflate_two.findViewById(R.id.rebuild_detial_accept_iv_arrow);
        line_two_body = (AutoLinearLayout) inflate_two.findViewById(R.id.check_accept_show_body);

        line_two_q_half = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_half);
        line_two_q_one = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_one);
        line_two_q_two = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_two);
        line_two_q_three = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_three);
        line_two_q_four = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_four);
        line_two_q_five = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five);

        line_two_q_five_six = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_six);
        line_two_q_five_seven = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_seven);
        line_two_q_five_eight = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_eight);
        line_two_q_five_nine = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_nine);
        line_two_q_five_ten = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_ten);
        line_two_q_five_eleven = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_eleven);
        line_two_q_five_twelve = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_five_twelve);


        line_two_q_six = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_six);
        line_two_q_seven = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_seven);
        line_two_q_eight = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_eight);
        line_two_q_nine = (TextView) inflate_two.findViewById(R.id.rdcs_tv_resault_nine);


        //第三个
        View inflate_three = infalte_questionlist.inflate();

        //RG
        rg_check_question_one = (RadioGroup) inflate_three.findViewById(R.id.rg_check_question_one);
        rg_check_question_two = (RadioGroup) inflate_three.findViewById(R.id.rg_check_question_two);
        rg_check_question_three = (RadioGroup) inflate_three.findViewById(rg_question_three);
        rg_check_question_four = (RadioGroup) inflate_three.findViewById(rg_question_four);
        rg_check_question_five = (RadioGroup) inflate_three.findViewById(rg_question_five);


        rg_check_question_five_half = (RadioGroup) inflate_three.findViewById(R.id.rg_question_five_half);
        rg_check_question_six = (RadioGroup) inflate_three.findViewById(R.id.rg_question_six);
        rg_check_question_seven = (RadioGroup) inflate_three.findViewById(R.id.rg_question_seven);
        rg_check_question_eight = (RadioGroup) inflate_three.findViewById(R.id.rg_question_eight);
        rg_check_question_nine = (RadioGroup) inflate_three.findViewById(R.id.rg_question_nine);
        rg_check_question_ten = (RadioGroup) inflate_three.findViewById(R.id.rg_question_ten);
        rg_check_question_eleven = (RadioGroup) inflate_three.findViewById(R.id.rg_question_eleven);
        rg_check_question_twelve = (RadioGroup) inflate_three.findViewById(R.id.rg_question_twelve);
        rg_check_question_thirdteen = (RadioGroup) inflate_three.findViewById(R.id.rg_question_thirdteen);
        rg_check_question_fourteen = (RadioGroup) inflate_three.findViewById(R.id.rg_question_fouthteen);
        rg_check_question_fifteen = (RadioGroup) inflate_three.findViewById(R.id.rg_question_fifteen);
        rg_check_question_sixteen = (RadioGroup) inflate_three.findViewById(R.id.rg_question_sixteen);
        rg_check_question_seventeen = (RadioGroup) inflate_three.findViewById(R.id.rg_question_seventeen);


        rb_one_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_one_pass);
        rb_one_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_one_fail);

        rb_two_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_two_pass);
        rb_two_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_two_fail);

        rb_three_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_three_pass);
        rb_three_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_three_fail);

        rb_four_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_four_pass);
        rb_four_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_four_fail);

        rb_five_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_five_pass);
        rb_five_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_five_fail);

        //=================

        rb_five_pass_half = (RadioButton) inflate_three.findViewById(R.id.check_detrb_five_half_pass);
        rb_five_fail_half = (RadioButton) inflate_three.findViewById(R.id.check_detrb_five_half_fail);

        rb_six_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_six_pass);
        rb_six_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_six_fail);
        rb_seven_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_seven_pass);
        rb_seven_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_seven_fail);
        rb_eight_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_eight_pass);
        rb_eight_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_eight_fail);
        rb_nine_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_nine_pass);
        rb_nine_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_nine_fail);
        rb_ten_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_ten_pass);
        rb_ten_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_ten_fail);
        rb_eleven_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_eleven_pass);
        rb_eleven_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_eleven_fail);
        rb_twelve_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_twelve_pass);
        rb_twelve_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_twelve_fail);
        rb_thirdteen_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_thirdteen_pass);
        rb_thirdteen_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_thirdteen_fail);
        rb_fouthteen_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_fouthteen_pass);
        rb_fouthteen_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_fouthteen_fail);
        rb_fifteen_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_fifteen_pass);
        rb_fifteen_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_fifteen_fail);
        rb_sixteen_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_sixteen_pass);
        rb_sixteen_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_sixteen_fail);
        rb_seventeen_pass = (RadioButton) inflate_three.findViewById(R.id.check_detrb_seventeen_pass);
        rb_seventeen_fail = (RadioButton) inflate_three.findViewById(R.id.check_detrb_seventeen_fail);


        //上传文件列表
        View inflate_four = inflat_up_image.inflate();
        upimg_statue = (TextView) inflate_four.findViewById(R.id.tv_upimg_check_statue);
        up_check_rl_a = (RelativeLayout) inflate_four.findViewById(R.id.up_check_rl_a);
        up_check_rl_b = (RelativeLayout) inflate_four.findViewById(R.id.up_check_rl_b);
        up_check_xiang = (RelativeLayout) inflate_four.findViewById(R.id.up_check_xiang);
        up_check_xian = (RelativeLayout) inflate_four.findViewById(R.id.up_check_xian);
        up_check_shi = (RelativeLayout) inflate_four.findViewById(R.id.up_check_shi);
        sell_check_one = (ImageView) inflate_four.findViewById(R.id.sell_check_one);
        sell_check_two = (ImageView) inflate_four.findViewById(R.id.sell_check_two);
        check_myFile_three = (ImageView) inflate_four.findViewById(R.id.check_myFile_three);
        check_myFile_four = (ImageView) inflate_four.findViewById(R.id.check_myFile_four);
        check_myFile_five = (ImageView) inflate_four.findViewById(R.id.check_myFile_five);
        image_check_a = (ImageView) inflate_four.findViewById(R.id.image_check_a);
        image_check_b = (ImageView) inflate_four.findViewById(R.id.image_check_b);
        image_check_xiang = (ImageView) inflate_four.findViewById(R.id.image_check_xiang);
        image_check_xian = (ImageView) inflate_four.findViewById(R.id.image_check_xian);
        image_check_shi = (ImageView) inflate_four.findViewById(R.id.image_check_shi);
        tv_img_biao = (TextView) inflate_four.findViewById(R.id.tv_img_biao);
        tv_img_yijian = (TextView) inflate_four.findViewById(R.id.tv_img_yijian);
        tv_img_xiang = (TextView) inflate_four.findViewById(R.id.tv_img_xiang);
        tv_img_xian = (TextView) inflate_four.findViewById(R.id.tv_img_xian);
        tv_img_shi = (TextView) inflate_four.findViewById(R.id.tv_img_shi);



    }

    /**
     * 加载余下的布局 并初始化
     */
    private void loadLayoutTwo() {
        ViewStub infalte_rest = (ViewStub) view.findViewById(R.id.inflat_check_rest);
        View inflate_rest_show = infalte_rest.inflate();
        tv_result = (TextView) inflate_rest_show.findViewById(R.id.check_det_tv_pull_choices);
        tv_group = (TextView) inflate_rest_show.findViewById(R.id.check_det_tv_checkance);
        tv_date_check_pickter = (TextView) inflate_rest_show.findViewById(R.id.check_det_tv_date);
        et_checkreason = (EditText) inflate_rest_show.findViewById(R.id.check_tv_fail_reason);
        all_check_det_unfail = (AutoLinearLayout) inflate_rest_show.findViewById(R.id.all_check_det_unfail);
        view_a_check = (View) inflate_rest_show.findViewById(R.id.view_a_check);
        bt_check_save = (Button) inflate_rest_show.findViewById(R.id.check_det_bt_save);


    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_check_detial, container, false);
        View detialLl = view.findViewById(R.id.check_buy_apply_ll);

        detialLl.setFocusable(true);
        detialLl.setFocusableInTouchMode(true);
        detialLl.requestFocus();

        return view;
    }


    /**
     * 动画结束后执行
     * 通过handler加载布局
     *
     * @param savedInstanceState
     */
    @Override
    public void onEnterAnimationEnd(Bundle savedInstanceState) {
        super.onEnterAnimationEnd(savedInstanceState);
        showLoadingDialog("正在加载....");


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_ONE);
            }
        }, 200);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_TWO);
            }
        }, 600);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_THREE);
            }
        }, 1200);
    }

    /**
     * 初始化公用布局,如:toolbar  scrollview
     *
     * @param view
     */
    private void initView(View view) {
        EventBus.getDefault().register(this);
        token_data = SPUtil.getString(Constants.KEY_TOKEN, "");

        //toolbar初始化
        applyBuySv = (ScrollView) view.findViewById(R.id.my_check_jescrollview);
        toolbarBack = (ImageView) view.findViewById(R.id.toolbar_back);
        toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
        toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        toolbarTitle.setText("户厕改造检查");
        //返回箭头
        toolbarBack.setVisibility(View.VISIBLE);
        //返回箭头功能 同步
        initToolbarBack(toolbar);

        //popuwindow添加数据
//        check_resaultlist.add("合格");
//        check_resaultlist.add("不合格");

        //时间选择器设置默认时间为当前时间
       // tv_date_check_pickter.setText("" + getNowTime());

        //=================获取保存的个人信息=============================
        UserEntity userEntity = MyApplication.getUserEntity();
        if(userEntity!=null){
            opt_level = userEntity.getOpt_level();
        }

        //=====================获取传递过来的值===========================

        Bundle arguments = getArguments();
        if (arguments != null) {
            checkItemBean = (CheckItemEntity.DataBean) arguments.getSerializable(CHECK_ITEM_BEAN);


            boolean edit = checkItemBean.isEdit();
            LogUtils.i("跳转接受过来的数据", "initView: " + edit);

            //false,不可编辑
            if (!edit) {
                //rb不可点击

                rb_one_pass.setClickable(false);
                rb_one_fail.setClickable(false);
                rb_two_pass.setClickable(false);
                rb_two_fail.setClickable(false);
                rb_three_pass.setClickable(false);
                rb_three_fail.setClickable(false);
                rb_four_pass.setClickable(false);
                rb_four_fail.setClickable(false);
                rb_five_pass.setClickable(false);
                rb_five_fail.setClickable(false);

                rb_five_pass_half.setClickable(false);
                rb_five_fail_half.setClickable(false);
                rb_six_pass.setClickable(false);
                rb_six_fail.setClickable(false);
                rb_seven_pass.setClickable(false);
                rb_seven_fail.setClickable(false);
                rb_eight_pass.setClickable(false);
                rb_eight_fail.setClickable(false);
                rb_nine_pass.setClickable(false);
                rb_nine_fail.setClickable(false);
                rb_ten_pass.setClickable(false);
                rb_ten_fail.setClickable(false);
                rb_eleven_pass.setClickable(false);
                rb_eleven_fail.setClickable(false);
                rb_twelve_pass.setClickable(false);
                rb_twelve_fail.setClickable(false);
                rb_thirdteen_pass.setClickable(false);
                rb_thirdteen_fail.setClickable(false);
                rb_fouthteen_pass.setClickable(false);
                rb_fouthteen_fail.setClickable(false);
                rb_fifteen_pass.setClickable(false);
                rb_fifteen_fail.setClickable(false);
                rb_sixteen_pass.setClickable(false);
                rb_sixteen_fail.setClickable(false);
                rb_seventeen_pass.setClickable(false);
                rb_seventeen_fail.setClickable(false);

                //验收结果,验收人,验收日期,保存按钮
                tv_result.setEnabled(false);
                tv_group.setEnabled(false);
                tv_date_check_pickter.setEnabled(false);

                et_checkreason.setEnabled(false);
                et_checkreason.setFocusable(false);

                bt_check_save.setClickable(false);
                bt_check_save.setEnabled(false);
                bt_check_save.setBackgroundResource(R.drawable.toilet_sliding_tv_unselected);


            }


            if ("市级".equals(checkItemBean.getJiancha_level())){
                up_check_shi.setVisibility(View.VISIBLE);
            }else if ("县级".equals(checkItemBean.getJiancha_level())){
                up_check_xian.setVisibility(View.VISIBLE);
            }
        }

//=====================获取传递过来的值===========================

        getNetTimeNow();


    }

    private void getNetTimeNow() {
        new Thread(){
            @Override
            public void run() {
                netTime = NetTimeUtils.getNetTime();
            }
        }.start();
    }


    /**
     * 添加的各种监听
     */
    private void initListener() {

        rg_check_question_one.setOnCheckedChangeListener(this);
        rg_check_question_two.setOnCheckedChangeListener(this);
        rg_check_question_three.setOnCheckedChangeListener(this);
        rg_check_question_four.setOnCheckedChangeListener(this);
        rg_check_question_five.setOnCheckedChangeListener(this);

        rg_check_question_five_half.setOnCheckedChangeListener(this);
        rg_check_question_six.setOnCheckedChangeListener(this);
        rg_check_question_seven.setOnCheckedChangeListener(this);
        rg_check_question_eight.setOnCheckedChangeListener(this);
        rg_check_question_nine.setOnCheckedChangeListener(this);
        rg_check_question_ten.setOnCheckedChangeListener(this);
        rg_check_question_eleven.setOnCheckedChangeListener(this);
        rg_check_question_twelve.setOnCheckedChangeListener(this);
        rg_check_question_thirdteen.setOnCheckedChangeListener(this);
        rg_check_question_fourteen.setOnCheckedChangeListener(this);
        rg_check_question_fifteen.setOnCheckedChangeListener(this);
        rg_check_question_sixteen.setOnCheckedChangeListener(this);
        rg_check_question_seventeen.setOnCheckedChangeListener(this);

        tv_result.setOnClickListener(this);
        tv_group.setOnClickListener(this);
        line_one_click_body.setOnClickListener(this);
        line_two_click_body.setOnClickListener(this);
        tv_date_check_pickter.setOnClickListener(this);
        bt_check_save.setOnClickListener(this);

        imageview_b.setOnClickListener(this);
        imageview_f.setOnClickListener(this);
        imageview_m.setOnClickListener(this);
        imageview_id.setOnClickListener(this);
        imageview_df.setOnClickListener(this);
        image_check_gaizaozhongtwo.setOnClickListener(this);
        image_check_gaizaozhongthree.setOnClickListener(this);


        //上传图片
        up_check_rl_a.setOnClickListener(this);
        up_check_rl_b.setOnClickListener(this);
        up_check_xiang.setOnClickListener(this);
        up_check_xian.setOnClickListener(this);
        up_check_shi.setOnClickListener(this);
    }


    private boolean rb_one, rb_two, rb_three, rb_four, rb_five, rb_five_half,
            rb_six, rb_seven, rb_eight, rb_nine, rb_ten,
            rb_eleven, rb_twelve, rb_thirdteen, rb_fouthteen, rb_fifteen,
            rb_sixteen, rb_seventeen;

    /**
     * RadioButton选择与参数添加
     *
     * @param radioGroup
     * @param i
     */
    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {

//        switch (i) {
//            case R.id.check_detrb_one_pass:
//                qrbparams.put("fuhe_biaozhun_jc", "1");
//                rb_one = true;
//                break;
//            case R.id.check_detrb_one_fail:
//                qrbparams.put("fuhe_biaozhun_jc", "0");
//                rb_one = true;
//                break;
//            case R.id.check_detrb_two_pass:
//                qrbparams.put("fuhe_guifan_jc", "1");
//                rb_two = true;
//                break;
//            case R.id.check_detrb_two_fail:
//                qrbparams.put("fuhe_guifan_jc", "0");
//                rb_two = true;
//                break;
//            case R.id.check_detrb_three_pass:
//                qrbparams.put("has_cefang_jc", "1");
//                rb_three = true;
//                break;
//            case R.id.check_detrb_three_fail:
//                qrbparams.put("has_cefang_jc", "0");
//                rb_three = true;
//                break;
//            case R.id.check_detrb_four_pass://use_oldhance_jc
//                qrbparams.put("use_oldhance_jc", "1");
//                rb_four = true;
//                break;
//            case R.id.check_detrb_four_fail:
//                qrbparams.put("use_oldhance_jc", "0");
//                rb_four = true;
//                break;
//            case R.id.check_detrb_five_pass:
//                qrbparams.put("fuhe_hxc_jc", "1");
//                rb_five = true;
//                break;
//            case R.id.check_detrb_five_fail:
//                qrbparams.put("fuhe_hxc_jc", "0");
//                rb_five = true;
//                break;
//
//            //====
//            case R.id.check_detrb_five_half_pass:
//                qrbparams.put("bili_jc", "1");
//                rb_five_half = true;
//                break;
//            case R.id.check_detrb_five_half_fail:
//                qrbparams.put("bili_jc", "0");
//                rb_five_half = true;
//                break;
//
//
//            case R.id.check_detrb_six_pass:
//                qrbparams.put("rongjifuhe_jc","1");
//                rb_six=true;
//                break;
//            case R.id.check_detrb_six_fail:
//                qrbparams.put("rongjifuhe_jc","0");
//                rb_six=true;
//                break;
//
//            case R.id.check_detrb_seven_pass:
//                qrbparams.put("shenduhege_jc","1");
//                rb_seven=true;
//                break;
//            case R.id.check_detrb_seven_fail:
//                qrbparams.put("shenduhege_jc","0");
//                rb_seven=true;
//                break;
//            case R.id.check_detrb_eight_pass:
//                qrbparams.put("guandaoguifan_jc","1");
//                rb_eight=true;
//                break;
//            case R.id.check_detrb_eight_fail:
//                qrbparams.put("guandaoguifan_jc","0");
//                rb_eight=true;
//                break;
//            case R.id.check_detrb_nine_pass:
//                qrbparams.put("fengeshenshui_jc","1");
//                rb_nine=true;
//                break;
//            case R.id.check_detrb_nine_fail:
//                qrbparams.put("fengeshenshui_jc","0");
//                rb_nine=true;
//                break;
//            case R.id.check_detrb_ten_pass:
//                qrbparams.put("liuguanchakou_jc","1");
//                rb_ten=true;
//                break;
//            case R.id.check_detrb_ten_fail:
//                qrbparams.put("liuguanchakou_jc","0");
//                rb_ten=true;
//                break;
//            case R.id.check_detrb_eleven_pass:
//                qrbparams.put("cailiaofuhe_jc","1");
//                rb_eleven=true;
//                break;
//            case R.id.check_detrb_eleven_fail:
//                qrbparams.put("cailiaofuhe_jc","0");
//                rb_eleven=true;
//                break;
//            case R.id.check_detrb_twelve_pass:
//                qrbparams.put("youcefang_jc","1");
//                rb_twelve=true;
//                break;
//            case R.id.check_detrb_twelve_fail:
//                qrbparams.put("youcefang_jc","0");
//                rb_twelve=true;
//                break;
//            case R.id.check_detrb_thirdteen_pass:
//                qrbparams.put("youding_jc","1");
//                rb_thirdteen=true;
//                break;
//            case R.id.check_detrb_thirdteen_fail:
//                qrbparams.put("youding_jc","0");
//                rb_thirdteen=true;
//                break;
//            case R.id.check_detrb_fouthteen_pass:
//                qrbparams.put("youmen_jc","1");
//                rb_fouthteen=true;
//                break;
//            case R.id.check_detrb_fouthteen_fail:
//                qrbparams.put("youmen_jc","0");
//                rb_fouthteen=true;
//                break;
//            case R.id.check_detrb_fifteen_pass:
//                qrbparams.put("fangying_jc","1");
//                rb_fifteen=true;
//                break;
//            case R.id.check_detrb_fifteen_fail:
//                qrbparams.put("fangying_jc","0");
//                rb_fifteen=true;
//                break;
//            case R.id.check_detrb_sixteen_pass:
//                qrbparams.put("fangdong_jc","1");
//                rb_sixteen=true;
//                break;
//            case R.id.check_detrb_sixteen_fail:
//                qrbparams.put("fangdong_jc","0");
//                rb_sixteen=true;
//                break;
//            case R.id.check_detrb_seventeen_pass:
//                qrbparams.put("fangchou_jc","1");
//                rb_seventeen=true;
//                break;
//            case R.id.check_detrb_seventeen_fail:
//                qrbparams.put("fangchou_jc","0");
//                rb_seventeen=true;
//                break;
//
//            default:
//
//                break;
//        }

    }


    private boolean isFirstView = false;
    private boolean isSecondView = false;

    /**
     * 对应控件的点击
     *
     * @param view
     */
    @Override
    public void onClick(View view) {

        switch (view.getId()) {

            case R.id.rebuild_reform_state_title:

//                //默认是关闭
//                if (!isFirstView) {
//                    Util.openView(line_one_body);//展开
//                    Util.openImageView(line_one_arrow);
//                    isFirstView = true;
//                } else { //关闭
//                    Util.clossView(line_one_body);
//                    Util.closeImageView(line_one_arrow);
//                    isFirstView = false;
//                }


                //默认是展开
                if (!isFirstView) {

                    Util.clossView(line_one_body);
                    Util.closeImageViewFan(line_one_arrow);
                    isFirstView = true;
                } else { //展开
                    Util.openView(line_one_body);//展开
                    Util.openImageViewFan(line_one_arrow);

                    isFirstView = false;
                }

                break;

            case R.id.rebuild_detial_accept_title:
                //默认是关闭
                if (!isSecondView) {
                    Util.openView(line_two_body);//展开
                    Util.openImageView(line_two_arrow);
                    isSecondView = true;
                } else { //关闭
                    Util.clossView(line_two_body);
                    Util.closeImageView(line_two_arrow);
                    isSecondView = false;
                }
                break;
            //检查结果
            case R.id.check_det_tv_pull_choices:

                check_resaultlist.clear();
                //301 市  302 县  303 乡 304*
                String opt_level = MyApplication.getUserEntity().getOpt_level();
                if (false) {

                    check_resaultlist.add("不合格");
                } else {
                    check_resaultlist.add("合格");
                    check_resaultlist.add("不合格");
                }


                check_resault_popupWindow = new ListPopupWindow(_mActivity);
                setPopuData(view, check_resault_popupWindow, check_resaultlist);
                setPopuClickListener(new PopuClickListener() {
                    @Override
                    public void show(String mess) {
                        //Toast.makeText(_mActivity, "验收结果是: " + mess, Toast.LENGTH_SHORT).show();
                        tv_result.setText(mess);
                        //提交时添加验收结果
                        //qrbparams.put("accept_resault", mess);
                        //2019-09-04 不通过原因设置为与检查结果无关联
//                        switch (mess) {
//                            case "合格":
//                                et_checkreason.setHint("");
//                                et_checkreason.setEnabled(false);
//                                break;
//                            case "不合格":
//                                et_checkreason.setHint("请输入原因,文字个数小于100");
//                                et_checkreason.setEnabled(true);
//                                break;
//
//                            default:
//
//                                break;
//                        }
                    }
                });

                break;

            case R.id.check_det_tv_checkance:
                //Toast.makeText(_mActivity, "检查小组", Toast.LENGTH_SHORT).show();


                if (checkItemBean != null) {
                    Intent intent = new Intent(_mActivity, AccepterActivity.class);
                    //这个id貌似没用
                    intent.putExtra(Constants.YANSHOUREN, "检查");
                    intent.putExtra("level_item", checkItemBean.getJiancha_level());
                    startActivityForResult(intent, REQUEST_CODE_SELECT);
                }

                break;
            //检查日期
            case R.id.check_det_tv_date:
                TimePickerView.Type type = TimePickerView.Type.YEAR_MONTH_DAY;
                pvTime = new TimePickerView(_mActivity, type);
                String format = "yyyy-MM-dd";
                UtilPop.alertTimerPickerEh(getActivity(), pvTime, format, new UtilPop.TimerPickerCallBack() {
                    @Override
                    public void onTimeSelect(String date) {
                       // String nowTime = getNowTime();
                        String nowTime = netTime;
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        TimeUtils.getIntervalTime2(date, nowTime, ConstUtils.TimeUnit.DAY, sdf);
                        if (TimeUtils.getTypeValue() == 1) {
                            //showShortToast("选择时间不能晚于当前时间");
                            if (date.equals(getNowTime())) {
                                if (!getNowTime().equals(netTime)) {
                                    showAlertOnlyPos(_mActivity, "检查日期", "该日期不能晚于今天" + netTime);
                                }
                            }else{
                                //showShortToast("选择时间不能晚于当前时间");
                                showAlertOnlyPos(_mActivity, "检查日期", "选择时间不能晚于当前时间"+netTime);
                            }
                        } else {

                            if (date.equals(getNowTime())) {
                                if (!getNowTime().equals(netTime)) {
                                    showAlertOnlyPos(_mActivity, "检查日期", "该日期不能晚于今天" + netTime);
                                }else{
                                    tv_date_check_pickter.setText(date);
                                }
                            }else{
                                tv_date_check_pickter.setText(date);
                            }
                            //　选择时间　正确
                            //tv_date_check_pickter.setText(date);

                            //添加验收时间
                            //qrbparams.put("accept_date", date);
                        }
                    }
                });

                break;

            case R.id.check_det_bt_save:

                boolean checkParams = getCheckParams();
                if (checkParams) {

                    //至此参数添加完成,上传参数上传完成后恢复为默认状态
                    // syso(qrbparams);
                    showLoadingDialog();

                    SaveUpData();
                }


                break;

            case R.id.rebuild_reform_state_befor_image:

                GotoImageFg(imageview_b, "改造前");

                break;
            case R.id.rebuild_reform_state_ing_image:

                GotoImageFg(imageview_m, "改造中1", "重建中1");

                break;
            case R.id.rebuild_reform_state_after_image:

                GotoImageFg(imageview_f, "改造后", "重建后");

                break;
            case R.id.rebuild_reform_state_idcard_image:

                GotoImageFg(imageview_id, "身份证正面","身份证");

                break;
            case R.id.rebuild_reform_state_frontdoor_image:

                GotoImageFg(imageview_df, "大门照");

                break;
            case R.id.image_check_gaizaozhongtwo:
                GotoImageFg(image_check_gaizaozhongtwo, "改造中2", "重建中2");

                break;
            case R.id.image_check_gaizaozhongthree:
                GotoImageFg(image_check_gaizaozhongthree, "改造中3", "重建中3");

                break;


            case R.id.up_check_rl_a:

                mLayoutType = 4;
                showPhotoPic();

                break;
            case R.id.up_check_rl_b:
                mLayoutType = 5;
                showPhotoPic();


                break;
            case R.id.up_check_xiang:
                mLayoutType = 6;
                showPhotoPic();
                break;
            case R.id.up_check_xian:
                mLayoutType = 7;
                showPhotoPic();
                break;
            case R.id.up_check_shi:
                mLayoutType = 8;
                showPhotoPic();
                break;
            default:

                break;
        }

    }

    private int mLayoutType = -1;

    private void showPhotoPic() {
        String carrier = android.os.Build.MANUFACTURER;
        LogUtils.i("手机厂商", "showPhotoPic: " + carrier);
        showPhotoPicker();
    }

    private void showPhotoPicker() {
        PhotoPicker.builder()
                .setPhotoCount(1) //显示图片张
                .setPreviewEnabled(false)
                .start(_mActivity, this, PhotoPicker.REQUEST_CODE);
    }


    /**
     * 跳转的图片展示页
     *
     * @param imageview
     * @param contextValue
     */
    private void GotoImageFg(ImageView imageview, String contextValue) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntities != null
                && acceptImageEntities.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                if (contextValue.equals(acceptiamgedata.getFile_des())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
                }

            }
        }

    }

    private void GotoImageFg(ImageView imageview, String contextValue, String value2) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntities != null
                && acceptImageEntities.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                if (contextValue.equals(acceptiamgedata.getFile_des()) || value2.equals(acceptiamgedata.getFile_des())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
                }

            }
        }

    }


    /**
     * 获取的提交数据
     */
    private void SaveUpData() {



        String check_up_save_url = HttpApis.checkDetialSaveUp + checkItemBean.getJiancha_id();

        LogUtils.i("检查详情提交参数", "url: " + check_up_save_url);

        qrbparams.put("idfield", "jiancha_id");

        qrbparams.put("buchongfu", getBuChongfuTime());

       // Map<String,String> map1 =new IdentityHashMap<String,String>(100);

//        map1.put(new String("idfield"), "jiancha_id");
//        map1.put(new String("jiancha_result"), qrbparams.get("jiancha_result"));
//        map1.put(new String("jiancha_result_n"), qrbparams.get("jiancha_result_n"));
//        map1.put(new String("jiancha_time"), qrbparams.get("jiancha_time"));
//        map1.put(new String("jiancha_remark"), qrbparams.get("jiancha_remark"));
//        map1.put(new String("jiancha_opt_n"), qrbparams.get("jiancha_opt_n"));
//        map1.put(new String("jiancha_opt"), qrbparams.get("jiancha_opt"));
//        map1.put(new String("buchongfu"),qrbparams.get("buchongfu"));
//        map1.put(new String("jiancha_opt_members"),qrbparams.get("jiancha_opt_members"));
//        map1.put(new String("adjunct_id"), recordlist_ima[0]);
//        map1.put(new String("adjunct_id"), advice_ima[0]);
//        map1.put(new String("sys_file_name"), recordlist_ima[1]);
//        map1.put(new String("sys_file_name"), advice_ima[1]);
//        map1.put(new String("adjunct_type"), recordlist_ima[2]);
//        map1.put(new String("adjunct_type"), advice_ima[2]);
//        map1.put(new String("file_type"), recordlist_ima[3]);
//        map1.put(new String("file_type"),  advice_ima[3]);
//        map1.put(new String("file_size"), recordlist_ima[4]);
//        map1.put(new String("file_size"), advice_ima[4]);
//        map1.put(new String("file_des"), recordlist_ima[5]);
//        map1.put(new String("file_des"),advice_ima[5]);
//        map1.put(new String("user_file_name"), recordlist_ima[6]);
//        map1.put(new String("user_file_name"), advice_ima[6]);

        ArrayList<String>  adjunct_id=new ArrayList<>();
        adjunct_id.add(recordlist_ima[0]);
        adjunct_id.add(advice_ima[0]);
        //adjunct_id.add(advice_ima_xiang[0]);
        adjunct_id.add(advice_ima_xian[0]);
        adjunct_id.add(advice_ima_shi[0]);
        ArrayList<String>  sys_file_name=new ArrayList<>();
        sys_file_name.add(recordlist_ima[1]);
        sys_file_name.add(advice_ima[1]);
        //sys_file_name.add(advice_ima_xiang[1]);
        sys_file_name.add(advice_ima_xian[1]);
        sys_file_name.add(advice_ima_shi[1]);
        ArrayList<String>  adjunct_type=new ArrayList<>();
        adjunct_type.add(recordlist_ima[2]);
        adjunct_type.add(advice_ima[2]);
        //adjunct_type.add(advice_ima_xiang[2]);
        adjunct_type.add(advice_ima_xian[2]);
        adjunct_type.add(advice_ima_shi[2]);

        ArrayList<String>  file_type=new ArrayList<>();
        file_type.add(recordlist_ima[3]);
        file_type.add(advice_ima[3]);
        //file_type.add(advice_ima_xiang[3]);
        file_type.add(advice_ima_xian[3]);
        file_type.add(advice_ima_shi[3]);

        ArrayList<String>  file_size=new ArrayList<>();
        file_size.add(recordlist_ima[4]);
        file_size.add(advice_ima[4]);
        //file_size.add(advice_ima_xiang[4]);
        file_size.add(advice_ima_xian[4]);
        file_size.add(advice_ima_shi[4]);

        ArrayList<String>  file_des=new ArrayList<>();
        file_des.add(recordlist_ima[5]);
        file_des.add(advice_ima[5]);
        //file_des.add(advice_ima_xiang[5]);
        file_des.add(advice_ima_xian[5]);
        file_des.add(advice_ima_shi[5]);

        ArrayList<String>  user_file_name=new ArrayList<>();
        user_file_name.add(recordlist_ima[6]);
        user_file_name.add(advice_ima[6]);
        //user_file_name.add(advice_ima_xiang[6]);
        user_file_name.add(advice_ima_xian[6]);
        user_file_name.add(advice_ima_shi[6]);

        ArrayList<String>  picmd5code=new ArrayList<>();
        picmd5code.add(recordlist_ima[7]);
        picmd5code.add(advice_ima[7]);
        //picmd5code.add(advice_ima_xiang[7]);
        picmd5code.add(advice_ima_xian[7]);
        picmd5code.add(advice_ima_shi[7]);

        qrbparams.put("adjunct_id", adjunct_id);
        qrbparams.put("sys_file_name", sys_file_name);
        qrbparams.put("adjunct_type", adjunct_type);
        qrbparams.put("file_type", file_type);
        qrbparams.put("file_size", file_size);
        qrbparams.put("file_des", file_des);
        qrbparams.put("user_file_name", user_file_name);
        qrbparams.put("picmd5code", picmd5code);

        qrbparams.put("token",token_data);
        HttpUtils.requestPostGson(_mActivity, check_up_save_url,qrbparams,new Request() {

            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.i("检查详情提交参数", "success: " + jsonStr);
                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);

                if (fileeditip != null && "success".equals(fileeditip.getState())) {
                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();


                    //提交完成后
                    qrbparams.clear();


                    tv_result.setText("下拉选择");
                    et_checkreason.setText("");

                    tv_group.setText("点击选择验收人");

                    rg_check_question_one.clearCheck();
                    rg_check_question_two.clearCheck();
                    rg_check_question_three.clearCheck();
                    rg_check_question_four.clearCheck();
                    rg_check_question_five.clearCheck();

                    EventBus.getDefault().post(new MessageEvent("363"));

                    //跳转到检查列表页
                    _mActivity.onBackPressed();
                }


                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.i("检查详情提交参数", "error: " + error);
                cancelLoadingDialog();
            }
        });



//        HttpUtils.requestPost(_mActivity, check_up_save_url,map1,new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//                LogUtils.i("检查详情提交参数", "success: " + jsonStr);
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//
//                    //提交完成后
//                    qrbparams.clear();
//
//
//                    tv_result.setText("下拉选择");
//                    et_checkreason.setText("");
//
//                    tv_group.setText("点击选择验收人");
//
//                    rg_check_question_one.clearCheck();
//                    rg_check_question_two.clearCheck();
//                    rg_check_question_three.clearCheck();
//                    rg_check_question_four.clearCheck();
//                    rg_check_question_five.clearCheck();
//
//                    EventBus.getDefault().post(new MessageEvent("363"));
//
//                    //跳转到检查列表页
//                    _mActivity.onBackPressed();
//                }
//
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                LogUtils.i("检查详情提交参数", "error: " + error);
//                cancelLoadingDialog();
//            }
//        });

        //0521
//        HttpUtils.requestPostUrl(_mActivity, check_up_save_url, new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//                LogUtils.i("检查详情提交参数", "success: " + jsonStr);
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//
//                    //提交完成后
//                    qrbparams.clear();
//
//
//                    tv_result.setText("下拉选择");
//                    et_checkreason.setText("");
//
//                    tv_group.setText("点击选择验收人");
//
//                    rg_check_question_one.clearCheck();
//                    rg_check_question_two.clearCheck();
//                    rg_check_question_three.clearCheck();
//                    rg_check_question_four.clearCheck();
//                    rg_check_question_five.clearCheck();
//
//                    EventBus.getDefault().post(new MessageEvent("363"));
//
//                    //跳转到检查列表页
//                    _mActivity.onBackPressed();
//                }
//
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                LogUtils.i("检查详情提交参数", "error: " + error);
//                cancelLoadingDialog();
//            }
//        });







        //更早
//        HttpUtils.requestPost(_mActivity, check_up_save_url, qrbparams, new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//                LogUtils.i("检查详情提交参数", "success: " + jsonStr);
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//
//                    //提交完成后
//                    qrbparams.clear();
//
//
//                    tv_result.setText("下拉选择");
//                    et_checkreason.setText("");
//
//                    tv_group.setText("点击选择验收人");
//
//                    rg_check_question_one.clearCheck();
//                    rg_check_question_two.clearCheck();
//                    rg_check_question_three.clearCheck();
//                    rg_check_question_four.clearCheck();
//                    rg_check_question_five.clearCheck();
//
//                    EventBus.getDefault().post(new MessageEvent("363"));
//
//                    //跳转到检查列表页
//                    _mActivity.onBackPressed();
//                }
//
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                LogUtils.i("检查详情提交参数", "error: " + error);
//                cancelLoadingDialog();
//            }
//        });

    }

    private void getMembers(String groupId) {
        String url=HttpApis.xiaozu;
        Map<String,String> params=new HashMap<>();
        params.put("groupIds",groupId);
        params.put("token",token_data);
        HttpUtils.requestPost(_mActivity, url,params,new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.i("小组成员", "success: " + jsonStr);

                MemberEntity memberEntity = new Gson().fromJson(jsonStr, MemberEntity.class);
                qrbparams.put("jiancha_opt_members",memberEntity.getValue());


                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.i("小组成员", "error: " + error);
                cancelLoadingDialog();
            }
        });

    }

    private String getBuChongfuTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }


    /**
     * 提交数据前检查参数
     */
    private boolean getCheckParams() {
        //确定5道选择题已经添加
//        if (!rb_five_half||!rb_six || !rb_seven || !rb_eight || !rb_nine || !rb_ten ||
//                !rb_eleven || !rb_twelve || !rb_thirdteen || !rb_fouthteen || !rb_fifteen||
//                !rb_sixteen || !rb_seventeen ){
//            showShortToast("请完善问答规范");
//            return false;
//        }

        //2019-09-05  需求变更，添加上传照片
//        if (!isRecordlistSuccess || !isAdviceSuccess) {
//            showAlertOnlyPos(_mActivity, "照片", "请上传检查记录表和检查意见照片");
//            return false;
//        }
        //301 市  302 县  303 乡 304村
//        if("301".equals(opt_level)&&!isShiSuccess){
//            showAlertOnlyPos(_mActivity, "照片", "请上传市现场验收照片");
//            return false;
//        }
//        if("302".equals(opt_level)&&!isXianSuccess){
//            showAlertOnlyPos(_mActivity, "照片", "请上传县现场验收照片");
//            return false;
//        }
//        if("303".equals(opt_level)&&!isXiangSuccess){
//            showAlertOnlyPos(_mActivity, "照片", "请上传乡现场验收照片");
//            return false;
//        }

        if ("市级".equals(checkItemBean.getJiancha_level())&&!isShiSuccess){
            showAlertOnlyPos(_mActivity, "照片", "请上传市现场验收照片");
            return false;
        }
        if ("县级".equals(checkItemBean.getJiancha_level())&&!isXianSuccess){
            showAlertOnlyPos(_mActivity, "照片", "请上传县现场验收照片");
            return false;
        }

        //检查验收结果
        String check_result = tv_result.getText().toString().trim();
        if (TextUtils.isEmpty(check_result) || "下拉选择".equals(check_result) || "未检查".equals(check_result)) {
            showAlertOnlyPos(_mActivity, "检查结果", "请选择检查结果");
            return false;
        } else {
            switch (check_result) {
                case "合格":
                    qrbparams.put("jiancha_result", "1");
                    qrbparams.put("jiancha_result_n", "合格");
                    break;
                case "不合格":
                    qrbparams.put("jiancha_result", "0");
                    qrbparams.put("jiancha_result_n", "不合格");
                    break;

                default:

                    break;
            }

            String old_statue_ = SPUtil.getString(Constants.OLD_CHECK_STATE, "");
            if(!TextUtils.isEmpty(old_statue_)){
                qrbparams.put("old_jiancha_result", old_statue_);
            }
        }


        //检查小组
        String checker = tv_group.getText().toString().trim();
        if (TextUtils.isEmpty(checker) || "点击选择检查小组".equals(checker)) {
            showAlertOnlyPos(_mActivity, "检查小组", "请选择检查小组");
            return false;
        }



        //检查不通过原因  当检查结果为合格时，不通过原因为不可编辑，且值为空;当检查结果为不合格时，不通过原因为必填
        String et_reason = et_checkreason.getText().toString().trim();

        if("不合格".equals(check_result)){
            if(TextUtils.isEmpty(et_reason)){
                showAlertOnlyPos(_mActivity, "备注", "请输入不合格原因");
                return false;
            }else if(!TextUtils.isEmpty(et_reason)&&et_reason.length()>100){
                showAlertOnlyPos(_mActivity, "备注", "内容超过100个字符");
                return false;
            }

        }



        qrbparams.put("jiancha_remark", et_reason);


        //检查日期
        String date_pick = tv_date_check_pickter.getText().toString().trim();
        if ("点击选择时间".equals(date_pick)||TextUtils.isEmpty(date_pick)) {
            showAlertOnlyPos(_mActivity, "检查日期", "请确认检查日期");
            return false;
        } else {
            qrbparams.put("jiancha_time", date_pick);
            return true;
        }








        //2019-09-04 将检查原因设置为与检查结果无关联

//        if ("不合格".equals(check_result)) {
//            if (TextUtils.isEmpty(et_reason)) {
//                showAlertOnlyPos(_mActivity, "不通过原因", "请填写不通过原因");
//                return false;
//            }else{
//                qrbparams.put("jiancha_remark", et_reason);
//                return true;
//            }
//        } else if("合格".equals(check_result)) {
//            qrbparams.put("jiancha_remark", et_reason);
//            return true;
//        }else{
//            return false;
//        }

    }


    //请求码
    public static final int REQUEST_CODE_SELECT = 101;
    private String sbaccepterValue = "[";
    private String sbaccepterId = "[";

    /**
     * 跳转回传
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            //添加图片返回
            if (data != null && requestCode == REQUEST_CODE_SELECT) {

                Bundle bundle = data.getBundleExtra("inters");
                List<AcceptanceEntity> ava = (List<AcceptanceEntity>) bundle.getSerializable("bundle");
                for (int i = 0; i < ava.size(); i++) {
                    if (i != ava.size() - 1) {
                        sbaccepterValue = sbaccepterValue + ava.get(i).getText() + ",";
                        sbaccepterId = sbaccepterId + ava.get(i).getValue() + ",";
                    } else {
                        sbaccepterValue = sbaccepterValue + ava.get(i).getText();
                        sbaccepterId = sbaccepterId + ava.get(i).getValue();
                    }

                }

                sbaccepterValue = sbaccepterValue + ("]");
                sbaccepterId = sbaccepterId + ("]");


                LogUtils.i("获得验收人", "onActivityResult: " + sbaccepterValue.toString());
                LogUtils.i("获得验收人", "onActivityResult: " + sbaccepterId.toString());

                // qrbparams.put("jiancha_opt", checker);
                String opt=sbaccepterId.toString();
                String opt_n=sbaccepterValue.toString();
                opt=opt.replace("]","");
                opt=opt.replace("[","");
                opt_n=opt_n.replace("]","");
                opt_n=opt_n.replace("[","");

                tv_group.setText(opt_n);
                qrbparams.put("jiancha_opt_n", opt_n);
                qrbparams.put("jiancha_opt", opt);
                getMembers(opt);

                ava.clear();
                sbaccepterValue = "[";
                sbaccepterId = "[";

            } else if (resultCode == RESULT_OK && requestCode == PhotoPicker.REQUEST_CODE && data != null) {
                ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);

                //=========添加水印=========
                String absolutePath = photos.get(0);

                if(absolutePath.endsWith(":abc")){
                    absolutePath=absolutePath.substring(0,absolutePath.length()-4);
                    savePic(absolutePath);
                }


                //==========添加水印========

                showLoadingDialog("正在上传图片");
                for (int i = 0; i < photos.size(); i++) {
                    String uri = Uri.decode(photos.get(i));
                    if(uri.endsWith(":abc")){
                        uri=uri.substring(0,uri.length()-4);
                    }
                    LogUtils.e("uri", uri);
                    try {
                        compressWithRx(new File(uri));
                    } catch (Exception e) {
                        Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();

                    }
                }

            }
        }
    }

    private void savePic(String filename) {

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inSampleSize = 2;
        Bitmap bm= BitmapFactory.decodeFile(filename,options);


        File file = new File(filename);

        // stringToBitmap(file.getAbsolutePath());
        try {
            FileOutputStream fos = new FileOutputStream(file);
//			FileInputStream fis = new FileInputStream(new File(tempPicPath)) ;
            byte[] temp = new byte[1024];
            //添加时间水印
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String time = sdf.format(new Date(System.currentTimeMillis()));

//            URL url = new URL("http://110.249.173.26:8081");
//            //url = new URL("http://www.baidu.com");
//            //url = new URL("http://www.ntsc.ac.cn");//中国科学院国家授时中心
//            //url = new URL("http://www.bjtime.cn");
//            URLConnection uc = url.openConnection();//生成连接对象
//            uc.connect(); //发出连接
//            long ld = uc.getDate(); //取得网站日期时间
//            Calendar calendar = Calendar.getInstance();
//            calendar.setTimeInMillis(ld);
//            int i = calendar.get(Calendar.YEAR);
//            int j = calendar.get(Calendar.MONTH);
//            j=j+1;
//            int x = calendar.get(Calendar.DAY_OF_MONTH);

            String time =netTime;

            String address = MyApplication.getAddress();
            if(address==null){
                address="";
            }
            if(address.contains("定位失败")){
                ToastUtils.showLongToast(_mActivity,"GPS在室内环境无法精准工作，请到室外进行定位尝试或打开WiFi按钮");
            }
            Bitmap newbm = ImageUtils.drawTextToRightBottom(_mActivity, bm, time+";"+ address,
                    25, ContextCompat.getColor(_mActivity,R.color.show2), 10, 10);


            //Bitmap newbmOne = addTimeFlag(_mActivity,newbm);
            newbm.compress(Bitmap.CompressFormat.JPEG, 100, fos);// 把数据写入文件
            fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    private void compressWithRx(File file) {

        Flowable.just(file)
                .observeOn(Schedulers.io())
                .map(new Function<File, File>() {
                    @Override
                    public File apply(@NonNull File file) {//  throws Exception
                        try {
                            File file1 = Luban.with(_mActivity).load(file).get();
                            return file1;
                        } catch (Exception e) {
                            //对于文件损坏的文件/压缩失败的文件,也能上传,但是,在主线程中提示
                            //记住,修改权限
                            _mActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    showShortToast("请重新上传");
                                }
                            });

                            return file;
                        }

                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<File>() {
                    @Override
                    public void accept(@NonNull File file) {
                        LogUtils.e("fileinfo", "file- " + file.length() / 1024 + "k" + " name- " + file.getName() + " paht- " + file.getPath());
                        //上传图片
                        if (file == null) {
                            Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();
                        } else {
                            uploadImgFile(file, file.getName(), file.getPath());
                        }

                    }


                });
    }

    private boolean isUploadSuccess;

    private void uploadImgFile(final File file, final String fileName, final String filepath) {
        String url = HttpApis.upload_image;
        HashMap<String, String> map = new HashMap<>();
        map.put("token",token_data);
        HttpUtils.requestPostFileMapUploades(getActivity(), url, fileName, file,map, new Request() {

            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.e("上传图片成功detial", "jsonSuccess  " + jsonStr);
                UploadImageEntity uploadImageEntity = GsonTools.changeGsonToBean(jsonStr, UploadImageEntity.class);
                if ("SUCCESS".equals(uploadImageEntity.getState())) {

                    if("0".equals(uploadImageEntity.getIsrepeat())){
                        isUploadSuccess = true;
                        displayUploadImgFile(uploadImageEntity, fileName);  //将img显示
                    }else{
                        showAlertOnlyPos(_mActivity,"图片上传","图片上传重复,请重新上传");
                        isUploadSuccess = false;
                    }


                } else {
                    //showShortToast("上传失败，图片大小不能超过4兆");
                    showAlertOnlyPos(_mActivity,"图片上传","上传失败，图片大小不能超过4兆");
                    isUploadSuccess = false;
                }
                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                isUploadSuccess = false;
                cancelLoadingDialog();
            }
        });

    }


    private String[] recordlist_ima = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_xiang = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_xian = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_shi = new String[]{null, null, null, null, null, null, null, null};
    private boolean isRecordlistSuccess;
    private boolean isAdviceSuccess;
    private boolean isXiangSuccess;
    private boolean isXianSuccess;
    private boolean isShiSuccess;

    private void displayUploadImgFile(UploadImageEntity uploadImageEntity, String fileName) {

        qrbparams.put("adj_table_info","bill_adjunct$business_id");
        switch (mLayoutType) {
            case 4:

                sell_check_one.setVisibility(View.GONE);
                image_check_a.setVisibility(View.VISIBLE);
//                LogUtils.i("上传图片成功", "展示图片 1 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath())
                        .into(image_check_a);

                up_check_rl_a.setBackgroundResource(R.color.status_translate);
                tv_img_biao.setText("检查记录表");

                recordlist_ima[0] = uploadImageEntity.getFileID();
                recordlist_ima[1] = uploadImageEntity.getFilePath();
                recordlist_ima[2] = "24";//adjunct_type : 据上传图片定
                recordlist_ima[3] = uploadImageEntity.getFileExt();
                recordlist_ima[4] = uploadImageEntity.getSize();
                recordlist_ima[5] = "检查记录表";//file_des:据上传图片定 身份证正面\大门照
                recordlist_ima[6] = fileName;
                recordlist_ima[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isRecordlistSuccess = isUploadSuccess;
                }
                break;
            case 5:

                sell_check_two.setVisibility(View.GONE);
                image_check_b.setVisibility(View.VISIBLE);
//                LogUtils.i("上传图片成功", "展示图片 2 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_check_b);

                up_check_rl_b.setBackgroundResource(R.color.status_translate);
                tv_img_yijian.setText("检查意见");

                advice_ima[0] = uploadImageEntity.getFileID();
                advice_ima[1] = uploadImageEntity.getFilePath();
                advice_ima[2] = "25";//adjunct_type : 据上传图片定
                advice_ima[3] = uploadImageEntity.getFileExt();
                advice_ima[4] = uploadImageEntity.getSize();
                advice_ima[5] = "检查意见";//file_des:据上传图片定 身份证正面\大门照
                advice_ima[6] = fileName;
                advice_ima[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isAdviceSuccess = isUploadSuccess;
                }
                break;
            case 6:

                check_myFile_three.setVisibility(View.GONE);
                image_check_xiang.setVisibility(View.VISIBLE);
//                LogUtils.i("上传图片成功", "展示图片 2 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_check_xiang);

                up_check_xiang.setBackgroundResource(R.color.status_translate);
                tv_img_xiang.setText("乡现场验收");

                advice_ima_xiang[0] = uploadImageEntity.getFileID();
                advice_ima_xiang[1] = uploadImageEntity.getFilePath();
                advice_ima_xiang[2] = "31";//adjunct_type : 据上传图片定
                advice_ima_xiang[3] = uploadImageEntity.getFileExt();
                advice_ima_xiang[4] = uploadImageEntity.getSize();
                advice_ima_xiang[5] = "乡现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xiang[6] = fileName;
                advice_ima_xiang[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isXiangSuccess = isUploadSuccess;
                }
                break;
            case 7:

                check_myFile_four.setVisibility(View.GONE);
                image_check_xian.setVisibility(View.VISIBLE);
//                LogUtils.i("上传图片成功", "展示图片 2 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_check_xian);

                up_check_xian.setBackgroundResource(R.color.status_translate);
                tv_img_xian.setText("县现场验收");

                advice_ima_xian[0] = uploadImageEntity.getFileID();
                advice_ima_xian[1] = uploadImageEntity.getFilePath();
                advice_ima_xian[2] = "32";//adjunct_type : 据上传图片定
                advice_ima_xian[3] = uploadImageEntity.getFileExt();
                advice_ima_xian[4] = uploadImageEntity.getSize();
                advice_ima_xian[5] = "县现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xian[6] = fileName;
                advice_ima_xian[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isXianSuccess = isUploadSuccess;
                }
                break;
            case 8:

                check_myFile_five.setVisibility(View.GONE);
                image_check_shi.setVisibility(View.VISIBLE);
//                LogUtils.i("上传图片成功", "展示图片 2 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_check_shi);

                up_check_shi.setBackgroundResource(R.color.status_translate);
                tv_img_shi.setText("市现场验收");

                advice_ima_shi[0] = uploadImageEntity.getFileID();
                advice_ima_shi[1] = uploadImageEntity.getFilePath();
                advice_ima_shi[2] = "33";//adjunct_type : 据上传图片定
                advice_ima_shi[3] = uploadImageEntity.getFileExt();
                advice_ima_shi[4] = uploadImageEntity.getSize();
                advice_ima_shi[5] = "市现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_shi[6] = fileName;
                advice_ima_shi[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isShiSuccess = isUploadSuccess;
                }
                break;

            default:
                break;

        }

    }

    /**
     * 得到当前时间
     */
    private String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    /**
     * eventBus接受数据
     *
     * @param center
     */
    @Subscribe
    public void onEventThread(EventCenter center) {


    }


    /**
     * 显示listpopuwindow,并使用回调,显示数据
     *
     * @param view
     * @param mPopupWindow
     * @param datalist
     */
    private void setPopuData(View view, final ListPopupWindow mPopupWindow, final List<String> datalist) {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, datalist);
        mPopupWindow.setAdapter(adapter);

        //弹出的位置  弹出锚点
        mPopupWindow.setAnchorView(view);
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);

        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (popuClickListener != null) {
                    popuClickListener.show("" + datalist.get(position));
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();
    }

    //-------------设置popu传值接口-----------------------------------------------------------
    public PopuClickListener popuClickListener;

    public void setPopuClickListener(PopuClickListener popuClickListener) {
        this.popuClickListener = popuClickListener;
    }
//-------------设置popu传值接口-----------------------------------------------------------


    /**
     * 加载数据    根据不同的buyCertId加载出是查看状态还是可编辑状态
     */
    private void loadMoreData() {
        //加载user信息
        if (checkItemBean != null) {
            //LogUtils.i("检查详情页面", "loadMoreData: "+checkItemBean.getJiancha_result_n());
            String applyBuyModfiy = HttpApis.checkDetial_edit + checkItemBean.getJiancha_id();
            if (request == null) {
                request = new CheckDetialRequest();
            }
            HashMap<String, String> map = new HashMap<>();
            map.put("token",token_data);
            HttpUtils.requestGet(_mActivity, applyBuyModfiy,map, request);

            //获取图片数据



            getCheckImageData(checkItemBean.getJiancha_id());

        }

    }

    /**
     * 获取图片数据
     *
     * @param check_id
     */
    private void getCheckImageData(String check_id) {

        String accept_image_data = HttpApis.acceptDetial_image;//+acceptid

        LogUtils.e("检查图片数据", accept_image_data);
        Map<String, String> params = new TreeMap<>();
        params.put("mid", check_id);
        params.put("token",token_data);

        HttpUtils.requestPost(_mActivity, accept_image_data, params, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.e("检查图片数据", jsonStr);

                Type type = new TypeToken<ArrayList<AcceptImageEntity>>() {
                }.getType();

                acceptImageEntities = json2Collection(jsonStr, type);

                if (acceptImageEntities != null && acceptImageEntities.size() > 0) {
                    for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                        processImageData(acceptiamgedata);
                        LogUtils.e("检查图片数据", acceptiamgedata.getSys_file_name());
                    }


                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.e("验收图片数据", error);
                cancelLoadingDialog();
            }
        });

    }

    /**
     * 加载图片
     *
     * @param acceptiamgedata
     */
    private void processImageData(AcceptImageEntity acceptiamgedata) {

        switch (acceptiamgedata.getAdjunct_type()) {
            case "13":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }


                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imageview_b);
                tv_befor.setText(acceptiamgedata.getFile_des());
                break;
            case "1401":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imageview_m);
                tv_ing.setText(acceptiamgedata.getFile_des());
                break;
            case "1402":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }

                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_gaizaozhongtwo);
                tv_check_gaizaozhongtwo.setText(acceptiamgedata.getFile_des());

                break;

            case "1403":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }

                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_gaizaozhongthree);
                tv_check_gaizaozhongthree.setText(acceptiamgedata.getFile_des());

                break;
            case "15":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imageview_f);
                tv_after.setText(acceptiamgedata.getFile_des());
                break;
            case "11":
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imageview_id);
                tv_idcard.setText(acceptiamgedata.getFile_des());
                break;
            case "12":
                if (alls_check_othertwo.getVisibility() == View.GONE) {
                    alls_check_othertwo.setVisibility(View.VISIBLE);
                }
                if (all_show_a.getVisibility() == View.GONE) {
                    all_show_a.setVisibility(View.VISIBLE);
                }
                if (all_show_b.getVisibility() == View.GONE) {
                    all_show_b.setVisibility(View.VISIBLE);
                }
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imageview_df);
                tv_frontdoor.setText(acceptiamgedata.getFile_des());
                break;

            case "24":
                sell_check_one.setVisibility(View.GONE);
                image_check_a.setVisibility(View.VISIBLE);
                isRecordlistSuccess = true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_a);
                tv_img_biao.setText(acceptiamgedata.getFile_des());

                recordlist_ima[0] = acceptiamgedata.getAdjunct_id();
                recordlist_ima[1] = acceptiamgedata.getSys_file_name();
                recordlist_ima[2] = "24";//adjunct_type : 据上传图片定
                recordlist_ima[3] = acceptiamgedata.getFile_type();
                recordlist_ima[4] = acceptiamgedata.getFile_size();
                recordlist_ima[5] = "检查记录表";//file_des:据上传图片定 身份证正面\大门照
                recordlist_ima[6] = acceptiamgedata.getUser_file_name();
                recordlist_ima[7] = acceptiamgedata.getPicmd5code();
                break;
            case "25":
                sell_check_two.setVisibility(View.GONE);
                image_check_b.setVisibility(View.VISIBLE);
                isAdviceSuccess = true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_b);
                tv_img_yijian.setText(acceptiamgedata.getFile_des());

                advice_ima[0] = acceptiamgedata.getAdjunct_id();
                advice_ima[1] = acceptiamgedata.getSys_file_name();
                advice_ima[2] = "25";//adjunct_type : 据上传图片定
                advice_ima[3] = acceptiamgedata.getFile_type();
                advice_ima[4] = acceptiamgedata.getFile_size();
                advice_ima[5] = "检查意见";//file_des:据上传图片定 身份证正面\大门照
                advice_ima[6] = acceptiamgedata.getUser_file_name();
                advice_ima[7] = acceptiamgedata.getPicmd5code();
                break;
            case "31":
                check_myFile_three.setVisibility(View.GONE);
                image_check_xiang.setVisibility(View.VISIBLE);
                isXiangSuccess = true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_xiang);
                tv_img_xiang.setText(acceptiamgedata.getFile_des());

                advice_ima_xiang[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_xiang[1] = acceptiamgedata.getSys_file_name();
                advice_ima_xiang[2] = "31";//adjunct_type : 据上传图片定
                advice_ima_xiang[3] = acceptiamgedata.getFile_type();
                advice_ima_xiang[4] = acceptiamgedata.getFile_size();
                advice_ima_xiang[5] = "乡现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xiang[6] = acceptiamgedata.getUser_file_name();
                advice_ima_xiang[7] = acceptiamgedata.getPicmd5code();
                break;
            case "32":
                check_myFile_four.setVisibility(View.GONE);
                image_check_xian.setVisibility(View.VISIBLE);
                isXianSuccess = true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_xian);
                tv_img_xian.setText(acceptiamgedata.getFile_des());

                advice_ima_xian[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_xian[1] = acceptiamgedata.getSys_file_name();
                advice_ima_xian[2] = "32";//adjunct_type : 据上传图片定
                advice_ima_xian[3] = acceptiamgedata.getFile_type();
                advice_ima_xian[4] = acceptiamgedata.getFile_size();
                advice_ima_xian[5] = "县现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xian[6] = acceptiamgedata.getUser_file_name();
                advice_ima_xian[7] = acceptiamgedata.getPicmd5code();
                break;
            case "33":
                check_myFile_five.setVisibility(View.GONE);
                image_check_shi.setVisibility(View.VISIBLE);
                isShiSuccess = true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_check_shi);
                tv_img_shi.setText(acceptiamgedata.getFile_des());

                advice_ima_shi[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_shi[1] = acceptiamgedata.getSys_file_name();
                advice_ima_shi[2] = "33";//adjunct_type : 据上传图片定
                advice_ima_shi[3] = acceptiamgedata.getFile_type();
                advice_ima_shi[4] = acceptiamgedata.getFile_size();
                advice_ima_shi[5] = "市现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_shi[6] = acceptiamgedata.getUser_file_name();
                advice_ima_shi[7] = acceptiamgedata.getPicmd5code();
                break;

            default:

                break;
        }

    }


    /**
     * 请求检查编辑详情数据
     */
    private class CheckDetialRequest extends Request {

        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);
            LogUtils.i("检查详情页面", "success" + jsonStr);

            //处理修改的数据
            //CheckDetialDataEntity checkdata = GsonTools.changeGsonToBean(jsonStr, CheckDetialDataEntity.class);
            CheckDetialTwoDataEntity checkdata = GsonTools.changeGsonToBean(jsonStr, CheckDetialTwoDataEntity.class);
            if (checkdata != null) {
                processModfiyData(checkdata);
            }
            cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.i("检查详情页面", "error" + error);
            cancelLoadingDialog();
        }
    }

    /**
     * 处理显示数据
     *
     * @param checkdata
     */
    private void processModfiyData(CheckDetialTwoDataEntity checkdata) {

        //===================================

        qrbparams.put("jiancha_opt", checkdata.getJiancha_opt());
        qrbparams.put("jiancha_opt_n", checkdata.getJiancha_opt_n());
        qrbparams.put("jiancha_result_n", checkdata.getJiancha_result_n());
        qrbparams.put("upt_time",checkdata.getNow());
        qrbparams.put("old_jiancha_result",checkdata.getJiancha_result());
        qrbparams.put("yanshou_id",checkdata.getJiancha_id());
        qrbparams.put("gaizao_id",checkdata.getGaizao_id());
        qrbparams.put("opt_id",checkdata.getOpt_id());
        qrbparams.put("opt_level",checkdata.getOpt_level());
        qrbparams.put("update_count",checkdata.getUpdate_count());

        String update_count = checkdata.getUpdate_count();
        int upCount = Integer.parseInt(update_count);
        if(upCount>=3){
            bt_check_save.setEnabled(false);
            bt_check_save.setClickable(false);
            bt_check_save.setBackgroundResource(R.drawable.toilet_sliding_tv_unselected);
        }


        //===================================



        //加载第一部分数据
        line_one_danwei.setText(checkdata.getArea_name());
        line_one_door_num.setText(checkdata.getMenpaihao());
        line_one_door_name.setText(checkdata.getHuming());
        line_one_househole_num.setText(checkdata.getHubianhao());
        line_one_id_num.setText(checkdata.getCert_no());
        line_one_idle.setText(checkdata.getXianzhi_n());
        line_one_build_state.setText(checkdata.getGaizao_state_n());
        line_one_build_type.setText(checkdata.getGaizao_type_n());
        rebuild_build_style.setText(checkdata.getGaizao_fangshi_n());

        line_one_build_year.setText(checkdata.getStat_year_n());

        line_one_team_name.setText(checkdata.getShgd_name());
        line_one_state_material.setText(checkdata.getHfc_material_n());

        line_one_humans.setText(checkdata.getRenkou());
        line_one_phones.setText(checkdata.getPhone());

        line_one_state_bianchi.setText(checkdata.getBianchi_n());
        line_one_state_chongshui.setText(checkdata.getChongshuifangshi_n());
        line_one_state_cefang.setText(checkdata.getCefang_n());

        getCheckImageData(checkdata.getGaizao_id());


        //加载第二部分数据
//        setQuestionValue(checkdata.getBili(), line_two_q_half);
//        setQuestionValue(checkdata.getRongjifuhe(), line_two_q_one);
//        setQuestionValue(checkdata.getShenduhege(), line_two_q_two);
//        setQuestionValue(checkdata.getGuandaoguifan(), line_two_q_three);
//        setQuestionValue(checkdata.getFengeshenshui(), line_two_q_four);
//        setQuestionValue(checkdata.getLiuguanchakou(), line_two_q_five);
//
//        setQuestionValue(checkdata.getCailiaofuhe(), line_two_q_five_six);
//        setQuestionValue(checkdata.getYoucefang(), line_two_q_five_seven);
//        setQuestionValue(checkdata.getYouding(), line_two_q_five_eight);
//        setQuestionValue(checkdata.getYoumen(), line_two_q_five_nine);
//        setQuestionValue(checkdata.getFangying(), line_two_q_five_ten);
//        setQuestionValue(checkdata.getFangdong(), line_two_q_five_eleven);
//        setQuestionValue(checkdata.getFangchou(), line_two_q_five_twelve);

        line_two_q_six.setText(checkdata.getYanshou_result_n());
        line_two_q_seven.setText(checkdata.getYanshou_opt_n());

        //检查日期
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        String stringDate = format.format(checkdata.getYanshou_time());
//        line_two_q_eight.setText(stringDate);
//        line_two_q_nine.setText(checkdata.getYanshou_remark());

        //检查结果yanshou_result_n
        if (!TextUtils.isEmpty(checkdata.getJiancha_result_n())) {
            tv_result.setText(checkdata.getJiancha_result_n());
            if (!"-1".equals(checkdata.getJiancha_result())) {
                qrbparams.put("jiancha_result", checkdata.getJiancha_result());

                if(!TextUtils.isEmpty(checkdata.getJiancha_result())){
                    SPUtil.putString(Constants.OLD_CHECK_STATE,checkdata.getJiancha_result());
                }

                qrbparams.put("jiancha_result_n", checkdata.getJiancha_result_n());
                tv_result.setEnabled(false);
                //2019-09-04 检查  不通过原因与检查结果不关联
//                if ("1".equals(checkdata.getJiancha_result())) {
//                    all_check_det_unfail.setVisibility(View.GONE);
//                    view_a_check.setVisibility(View.GONE);
//                }

            }else{
                SPUtil.putString(Constants.OLD_CHECK_STATE,checkdata.getJiancha_result());
            }
        }

        //检查小组
        if (!TextUtils.isEmpty(checkdata.getJiancha_opt_n())) {
            String opt=checkdata.getJiancha_opt();
            opt=opt.replace("[","");
            opt=opt.replace("]","");

            String opt_n=checkdata.getJiancha_opt_n();
            opt_n=opt_n.replace("[","");
            opt_n=opt_n.replace("]","");

            tv_group.setText(opt_n);
            qrbparams.put("jiancha_opt", opt);
            qrbparams.put("jiancha_opt_n", opt_n);
            getMembers(opt);
        }

        upimg_statue.setText("请上传验收员到达现场和厕房位置的图片");


        //检查时间
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        Object jiancha_time = checkdata.getJiancha_time();

        try {

            String shg_date = checkdata.getJiancha_time();
            if (!TextUtils.isEmpty(shg_date)) {
                if(shg_date.contains(" ")){
                    String[] s_date = shg_date.split(" ");
                    tv_date_check_pickter.setText(s_date[0]);
                    qrbparams.put("jiancha_time", s_date[0]);
                }else{
                    tv_date_check_pickter.setText(shg_date);
                    qrbparams.put("jiancha_time", shg_date);
                }

            }
        } catch (Exception e) {
//            Date date = new Date();
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            try {
//                date.setTime((long) checkdata.getJiancha_time());
//
//                String jianchaDate = sdf.format(date);
//                tv_date_check_pickter.setText(jianchaDate);
//                qrbparams.put("jiancha_time", jianchaDate);
//            } catch (Exception ea) {
//                Double shg_date = (Double) checkdata.getJiancha_time();
//                long l = shg_date.longValue();
//                date.setTime(l);
//                String format = sdf.format(date);
//                tv_date_check_pickter.setText(format);
//                qrbparams.put("jiancha_time", format);
//
//            }

        }


        //2019-09-04 将不通过原因设置为可以为空
        //不通过原因
//        if (!TextUtils.isEmpty(checkdata.getJiancha_remark())) {
//            et_checkreason.setText(checkdata.getJiancha_remark());
//            qrbparams.put("jiancha_remark", checkdata.getJiancha_remark());
//        }
        et_checkreason.setText(checkdata.getJiancha_remark());
        qrbparams.put("jiancha_remark", checkdata.getJiancha_remark());


    }

    /**
     * 赋值
     *
     * @param value
     * @param tv
     */
    private void setQuestionValue(String value, TextView tv) {
        if (value != null && tv != null) {
            if ("1".equals(value)) {
                tv.setText("是");
            } else {
                tv.setText("否");
            }
        }

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();

        if (pvTime != null && pvTime.isShowing()) {
            pvTime.dismiss();
            pvTime = null;
        }

        EventBus.getDefault().unregister(this);
        OkHttpUtils.getInstance().cancelTag(this);
        cancelLoadingDialog();
        handler.removeCallbacksAndMessages(null);
    }
}
